package com.lzgcoding.onlineshopapp.util

import androidx.compose.ui.graphics.Color

fun String.toColor(): Color{
    val clean = this.removePrefix("#")
    val colorLong = when (clean.length) {
        6 -> "FF$clean" // if it is only RGB, plus FF means opaque
        8 -> clean      // if alpha is already included
        else -> throw IllegalArgumentException("Invalid color format: $this")
    }.toLong(16)
    return Color(colorLong)
}